package com.bys.exceptionhandler;

import com.bys.exception.BysOaSystemException;
import com.bys.response.Result;
import com.bys.response.ReultCode;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class CrmExceptionHandler {
    @ExceptionHandler(BysOaSystemException.class)
    public Result doBysOaException(BysOaSystemException e){
        e.printStackTrace();
        return Result.fail(e.getCode(),e.getMessage());
    }
    @ExceptionHandler
    public Result doException(Exception e){
        e.printStackTrace();
        return Result.fail(e.getMessage());
    }
    @ExceptionHandler(MethodArgumentNotValidException.class)
    public Result doMethodArgumentException(Exception e){
        e.printStackTrace();
        return Result.fail(ReultCode.ARGUMENT_ERROR);
    }

}
